package com.epfresh.supplier.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.epfresh.api.utils.MarketPermissionUtil;
import com.epfresh.supplier.Listener.IndexIconOnClickListener;
import com.epfresh.supplier.R;
import com.epfresh.supplier.entity.HomePart;
import com.epfresh.supplier.widget.CommonRecyclerAdapter;
import com.epfresh.supplier.widget.ViewHolder;

import java.util.List;

public class HomePart3Adapter extends CommonRecyclerAdapter<HomePart> {
    private IndexIconOnClickListener indexIconOnClickListener;

    public HomePart3Adapter(Context context, List<HomePart> datas) {
        super(context, datas, R.layout.home_part);
    }

    public void setDatas( List<HomePart> datas){
        super.setData(datas);
    }

    public void setListener(IndexIconOnClickListener indexIconOnClickListener) {
        this.indexIconOnClickListener = indexIconOnClickListener;
    }

    @Override
    public void convert(ViewHolder holder, final HomePart item, int position) {
        ImageView pic = holder.getView(R.id.iv_pic);
        RelativeLayout rlIcon = holder.getView(R.id.rl_icon);
        switch (item.getName()) {
            case MarketPermissionUtil.appSupplierStore:
                pic.setBackgroundResource(R.mipmap.my_stores);
                holder.setText(R.id.tv_name, "我的店铺");
                break;
            case MarketPermissionUtil.appSupplierProductPresell:
                pic.setBackgroundResource(R.mipmap.pre_sale_goods);
                holder.setText(R.id.tv_name, "预售商品");
                break;
            case MarketPermissionUtil.appSupplierJointOrder:
                pic.setBackgroundResource(R.mipmap.stock_up);
                holder.setText(R.id.tv_name, "备货");
                break;
            case MarketPermissionUtil.appSupplierProductOften_order:
                pic.setBackgroundResource(R.mipmap.grab_sheet);
                holder.setText(R.id.tv_name, "抢单");
                break;
            case MarketPermissionUtil.appSupplierComment:
                pic.setBackgroundResource(R.mipmap.evaluate);
                holder.setText(R.id.tv_name, "评价");
                break;
            case MarketPermissionUtil.appSupplierCoupon:
                pic.setBackgroundResource(R.mipmap.coupon);
                holder.setText(R.id.tv_name, "优惠券");
                break;
            case MarketPermissionUtil.appSupplierJointProduct:
                pic.setBackgroundResource(R.mipmap.offer);
                holder.setText(R.id.tv_name, "联营报价");
                break;
        }
        rlIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (indexIconOnClickListener != null) indexIconOnClickListener.onclick(item.getName());
            }
        });
    }
}
